<gmd:CI_ResponsibleParty id="contact-{{ role }}">
  {{ cs.get_freetext('individualName', record['metadata']['language_alternate'], get_charstring(contact.get('individualname'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
  {{ cs.get_freetext('organisationName', record['metadata']['language_alternate'], get_charstring(contact.get('organization'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
  {{ cs.get_freetext('positionName', record['metadata']['language_alternate'], get_charstring(contact.get('positionname'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
  <gmd:contactInfo>
    <gmd:CI_Contact>
      <gmd:phone>
        <gmd:CI_Telephone>
          {% if contact['phone'] %}
          <gmd:voice>
            <gco:CharacterString>{{ contact['phone'] }}</gco:CharacterString>
          </gmd:voice>
          {% else %}
          <gmd:voice gco:nilReason="missing"/>
          {% endif %}
          {% if contact['fax'] %}
          <gmd:facsimile>
            <gco:CharacterString>{{ contact['fax'] }}</gco:CharacterString>
          </gmd:facsimile>
          {% else %}
          <gmd:facsimile gco:nilReason="missing"/>
          {% endif %}
        </gmd:CI_Telephone>
      </gmd:phone>
      <gmd:address>
        <gmd:CI_Address>
          {{ cs.get_freetext('deliveryPoint', record['metadata']['language_alternate'], get_charstring(contact.get('address'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
          {{ cs.get_freetext('city', record['metadata']['language_alternate'], get_charstring(contact.get('city'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
          {{ cs.get_freetext('administrativeArea', record['metadata']['language_alternate'], get_charstring(contact.get('administrativearea'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
          <gmd:postalCode>
            <gco:CharacterString>{{ contact['postalcode'] }}</gco:CharacterString>
          </gmd:postalCode>
          {{ cs.get_freetext('country', record['metadata']['language_alternate'], get_charstring(contact.get('country'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
          {{ cs.get_freetext('electronicMailAddress', record['metadata']['language_alternate'], get_charstring(contact.get('email'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
        </gmd:CI_Address>
      </gmd:address>
      <gmd:onlineResource>
        <gmd:CI_OnlineResource>
          <gmd:linkage>
            <gmd:URL>{{ contact['url']|e }}</gmd:URL>
          </gmd:linkage>
          <gmd:protocol>
            <gco:CharacterString>WWW:LINK</gco:CharacterString>
          </gmd:protocol>
          <gmd:function>
            <gmd:CI_OnLineFunctionCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_OnLineFunctionCode" codeListValue="information" codeSpace="ISOTC211/19115">information</gmd:CI_OnLineFunctionCode>
          </gmd:function>
        </gmd:CI_OnlineResource>
      </gmd:onlineResource>
      {{ cs.get_freetext('hoursOfService', record['metadata']['language_alternate'], get_charstring(contact.get('hoursofservice'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
      {{ cs.get_freetext('contactInstructions', record['metadata']['language_alternate'], get_charstring(contact.get('contactinstructions'), record['metadata']['language'], record['metadata']['language_alternate'])) }}
    </gmd:CI_Contact>
  </gmd:contactInfo>
  <gmd:role>
    <gmd:CI_RoleCode codeList="http://wis.wmo.int/2011/schemata/iso19139_2007/schema/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeSpace="ISOTC211/19115" codeListValue="{{ role }}">{{ role }}</gmd:CI_RoleCode>
  </gmd:role>
</gmd:CI_ResponsibleParty>
